﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;
using DigitalRune.Windows.TextEditor.Bookmarks;
using DigitalRune.Windows.TextEditor;
using DigitalRune.Windows.TextEditor.Document;

namespace Zove.Desktop.Tools
{
    public partial class BookmarkView : DockContent
    {
        public BookmarkView()
        {
            InitializeComponent();
        }

        private IDesktopView form;

        public BookmarkView(IDesktopView form)
        {
            TextEditorControl control = form.GetTextEditorControl();
            if (control == null)
            {
                throw new ArgumentException("");
            }

            UpdateBookmarks(control.Document.BookmarkManager);
        }

        private void UpdateBookmarks(BookmarkManager bookmarkManager)
        {
            foreach (
                   Bookmark bookmark in
                   bookmarkManager.Marks)
            {
                this.gvBookmarks.Rows.Add(
                    new string[]{
                        "",
                        "",
                        bookmark.LineNumber.ToString()
                    });
            }
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            TextEditorControl control = form.GetTextEditorControl();
            BookmarkManager mgr = control.Document.BookmarkManager;
            Bookmark bookmark = mgr.Factory.CreateBookmark(
                control.Document,
                new TextLocation(
                    control.ActiveTextAreaControl.Location.X,
                    control.ActiveTextAreaControl.Location.Y)
                );
            UpdateBookmarks(control.Document.BookmarkManager);
        }

        private void toolStripButton8_Click(object sender, EventArgs e)
        {
            TextEditorControl control = form.GetTextEditorControl();
            BookmarkManager mgr = control.Document.BookmarkManager;
        }
    }
}
